package com.capIX.Threads;

public class ThreadEx9 extends Thread {
	StringBuffer sb = new StringBuffer();

	public ThreadEx9(StringBuffer sb) {
		this.sb = sb;

	}

	public void run() {

		synchronized (sb) {
			for (int i = 0; i <= 100; i++) {
				System.out.println(i + "" + sb);
			}

			/*
			 * incrementing the sb to the next value int this case A to B and C
			 */
			char c = sb.charAt(0);// char c takes the value of the string at
									// value 0
			c++;// incrementing
			String temp = Character.toString(c);// converting the char to string
			sb = sb.replace(0, 1, temp);// replacest the
		}
	}

	public static void main(String[] args) {
		StringBuffer sb = new StringBuffer("A");

		ThreadEx9 th1 = new ThreadEx9(sb);
		ThreadEx9 th2 = new ThreadEx9(sb);
		ThreadEx9 th3 = new ThreadEx9(sb);

		th1.start();
		th2.start();
		th3.start();

	}
}
